package ar.edu.unq.wannaplay.panels;

import org.apache.wicket.extensions.yui.calendar.DatePicker;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.model.CompoundPropertyModel;

import ar.edu.unq.wannaplay.utils.DateCollector;

public class DateFromAndToPanel extends NonServicedPanel {

    private static final long serialVersionUID = 1L;

    private DateCollector dateColector;

    public DateFromAndToPanel(final String id, final DateCollector fromTo) {
        super(id);
        dateColector = fromTo;
        this.initialize();
    }

    private void initialize() {
        CompoundPropertyModel bindTime = new CompoundPropertyModel(this.getDateColector());
        Form form = new Form("form", bindTime);
        form.add(this.generateTextField("start"));
        form.add(this.generateTextField("end"));
        this.add(form);

    }

    private TextField generateTextField(final String id) {
        TextField textField = new TextField(id);
        textField.add(new DatePicker());
        return textField;
    }

    public DateCollector getDateColector() {
        return dateColector;
    }

    public void setDateColector(final DateCollector date) {
        dateColector = date;
    }

}
